﻿using System;
using System.Collections.Generic;
using System.Data.OleDb;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;

namespace SolutionGenerator
{
    public enum WizardStep
    {
        W01_LoadConfiguration,
        W02_GetConnectionInfo,
        W03_GetTables,
        W04_ProcessFKChilds,
        W05_GetTemplates,
        W06_GenerateTemplate//,
        //W99_CompleteReport
    }
    public enum ForeignKeyType
    {
        Parent,
        Child
    }
    [DataContract]
    public class SolutionConfiguration
    {
        [DataMember]
        public string ConnectionString { get; set; }
        [DataMember]
        public List<SolutionConfigurationTableInfo> GetTableInfo { get; set; }
        [DataMember]
        public List<SolutionConfigurationFolderInfo> GetFolderInfo { get; set; }
    }
    [DataContract]
    public class SolutionConfigurationTableInfo
    {
        [DataMember]
        public string TableName { get; set; }
        [DataMember]
        public bool IsProcess { get; set; }
        [DataMember]
        public bool IsFKChildProcess { get; set; }
        [DataMember]
        public List<SolutionConfigurationColumnInfo> GetColumnInfo { get; set; }
        public string TableNameSmallCharInfront
        {
            get { return string.Format("{0}{1}", char.ToLower(TableName[0]), TableName.Substring(1)); }
        }
    }
    [DataContract]
    public class SolutionConfigurationColumnInfo
    {
        [DataMember]
        public string ColumnName { get; set; }
        [DataMember]
        public OleDbType ColumnDataType { get; set; }
        [DataMember]
        public Int64 ColumnLength { get; set; }
        [DataMember]
        public bool IsNullAble { get; set; }
        [DataMember]
        public string DefaultValue { get; set; }
        [DataMember]
        public List<SolutionConfigurationForeignKeyInfo> FKList { get; set; }
        public string ColumnNameSmallCharInfront
        {
            get { return string.Format("{0}{1}", char.ToLower(ColumnName[0]), ColumnName.Substring(1)); }
        }
    }
    [DataContract]
    public class SolutionConfigurationForeignKeyInfo
    {
        [DataMember]
        public string ForeignKeyName { get; set; }
        [DataMember]
        public ForeignKeyType FKType { get; set; }
        [DataMember]
        public string FKTable { get; set; }
        [DataMember]
        public string FKColumn { get; set; }
    }
    [DataContract]
    public class SolutionConfigurationFolderInfo
    {
        [DataMember]
        public string FolderLocation { get; set; }
        [DataMember]
        public string UseThisTemplate { get; set; }
        [DataMember]
        public string DataTypeTemplate { get; set; }
        [DataMember]
        public string NameFormat { get; set; }
    }
    [DataContract]
    public class SolutionConfigurationDataTypeTemplate
    {
        [DataMember]
        public OleDbType DataType { get; set; }
        [DataMember]
        public Dictionary<int, string> TemplateReplace { get; set; }
        [DataMember]
        public Dictionary<int, string> TemplateIsRequired { get; set; }
        [DataMember]
        public Dictionary<string, string> DefaultValueMap { get; set; }
    }
}